<?php

namespace app\api\controller;

use app\admin\model\LookResource;
use app\common\controller\Api;
use think\Request;

class Look extends Api
{

    protected $noNeedLogin = ['*'];
    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        $this->model = new \app\admin\model\Look();
    }

    public function getLookList()
    {
        $list = $this->model->where([])->paginate();
        $this->success('请求成功',$list);
    }
    public function getResourceList()
    {
        $look_id = $this->request->get('look_id');
        $model = new LookResource();
        $list = $model->where(['look_id'=>$look_id])->paginate();
        $lookNum = $model->where(['look_id'=>$look_id])->sum('look_num');
        $time = $model->where(['look_id'=>$look_id])->sum('time');
        $time =Handleminute($time);
        $data = [
            'list'=>$list,
            'lookNum'=>$lookNum,
            'time'=>$time,
        ];
        $this->success('请求成功',$data);
    }
    public function lookNum(){
        $id = $this->request->post('id');
        $model = new LookResource();

        $model->where(['id'=>$id])->setInc('look_num');
        $this->success('请求成功');
    }

}